package com.lkj;

import com.baidu.aip.face.AipFace;
import com.baidu.aip.face.MatchRequest;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class SimplSDK {


    //设置APPID/AK/SK
    public static final String APP_ID = "22424249";
    public static final String API_KEY = "PsSm8fEG7D9qSG0DXgpjYUCV";
    public static final String SECRET_KEY = "DHOHP3RG6PlogUaOv7imMGi3hUHkRcV6";

    public static void main(String[] args) {

        String s = faceMatch();
        System.out.println(s);
    }

    public static String faceMatch(){
        AipFace client = new AipFace(APP_ID, API_KEY, SECRET_KEY);

        String image1 = ImageUtil.getImage("lkj.jpg");

        String image2 = ImageUtil.getImage("likj.jpg");

        MatchRequest req1 = new MatchRequest(image1, "BASE64");
        MatchRequest req2 = new MatchRequest(image2, "BASE64");
        ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>();
        requests.add(req1);
        requests.add(req2);

        JSONObject res = client.match(requests);

        return res.toString();
    }

    public static String faceDetect(){
        AipFace client = new AipFace(APP_ID, API_KEY, SECRET_KEY);

        String image = ImageUtil.getImage("lkj.jpg");
        String imageType = "BASE64";
        HashMap<String,String> map = new HashMap<>();
        map.put("face_field","faceshape,facetype");
        map.put("face_type","LIVE");
        JSONObject detect = client.detect(image, imageType, map);
        return detect.toString();
    }
}
